//
//  TransactionCell.m
//  Futures
//
//  Created by Cheng on 2017/6/30.
//  Copyright © 2017年 Cheng. All rights reserved.
//

#import "TransactionCell.h"

@implementation TransactionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.raisePercent.layer.borderWidth = 1.0f;
    self.raisePercent.layer.cornerRadius = 3.0f;
    
    self.raisePercent.layer.borderColor = [UIColor redColor].CGColor;
    self.raisePercent.layer.masksToBounds = YES;
}

- (void)setCellWithModel:(QuoteModel *)model{
    self.goods.text = model.Symbolname;
    
    self.code.text = model.Exchange;
    
    self.nowPrice.text = [NSString stringWithFormat:@"%.2f",model.LastPrice];
    
    self.dealVolume.text = [NSString stringWithFormat:@"%d",model.Vol];
    
//    double raisePercent = (model.LastPrice - model.open)/model.open*100;
    
    self.raisePercent.text = [NSString stringWithFormat:@"%.2f%%",model.ChangeRate];
    
    if (model.ChangeRate == 0) {
        self.nowPrice.textColor = [UIColor whiteColor];
        self.raisePercent.textColor = [UIColor whiteColor];
        self.raisePercent.layer.borderColor = [UIColor whiteColor].CGColor;
    }else if (model.ChangeRate < 0){
        self.nowPrice.textColor = [UIColor greenColor];
        self.raisePercent.textColor = [UIColor greenColor];
        self.raisePercent.layer.borderColor = [UIColor greenColor].CGColor;
    }
    
//    if (model.open==0) {
//        self.raisePercent.text = @"0.00%";
//    }
    
//    MYLog(@"%.2f",model.Change);
}

@end
